package com.example.commons.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * Author:汪彬彬
 * date:2024/11/12 16:29
 */
public class DateUtils {

    /**
     * 时间格式(yyyy-MM-dd)
     */
    public final static String DATE_PATTERN = "yyyy-MM-dd";
    /**
     * 时间格式(yyyy-MM-dd HH:mm:ss)
     */
    public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

    public final static String SUBJECT_DATE = "yyyy/MM/dd";

    public final static String TIME_PATTERN = "HH:mm:ss";


    /**
     * string格式的日期转 date
     */
    public static String string2Date(final String dateStr) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
        Date parse = dateFormat.parse(dateStr);
        return dateFormat.format(parse).substring(0,10);
    }

    /**
     * string格式的日期转 Time
     */
    public static String string2Time(final String dateStr) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
        Date parse = dateFormat.parse(dateStr);
        return dateFormat.format(parse).substring(11,19);
    }
   static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static LocalDate getNextDay(){
        LocalDate today = LocalDate.now();
        // 获取明天的日期
        LocalDate tomorrow = today.plusDays(1);
        return tomorrow;
    }

    public static Long getNextDaytoLong() {
        try {
            String date = getNextDay() + " 00:00:00";
            Long a = sdf.parse(date).getTime();
            return  a;
        } catch (Exception e) {

        }
        return null;
    }
    public static void main(String[] args) {
        System.out.println(getNextDaytoLong());
    }


}
